package com.ztesoft.web.baseconfig.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ztesoft.core.common.Page;
import com.ztesoft.framework.exception.BaseAppException;
import com.ztesoft.framework.log.ZTEsoftLogManager;
import com.ztesoft.web.baseconfig.db.po.DmPlanRelationPO;
import com.ztesoft.web.baseconfig.service.IDmPlanRelationService;

/**
 * <Description>计划与策略关系管理 <br>
 * 
 * @author lin.jie <br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2015年8月4日 <br>
 * @since V1.0<br>
 * @see com.ztesoft.web.baseconfig.controller <br>
 */

@Controller
@RequestMapping("/cleaner/baseconfig/dmplanrelation")
public class DmPlanRelationController {

	private static final ZTEsoftLogManager logger = ZTEsoftLogManager.getLogger(DmPlanRelationController.class);

	@Autowired
	private IDmPlanRelationService dmPlanRelationService;

	@RequestMapping("index")
	public String index(Model model) {
		return "cleaner/baseconfig/jsp/dmPlanRelation";
	}

	@RequestMapping("queryRecordByPage")
	@ResponseBody
	public Page<DmPlanRelationPO> queryRecordByPage(DmPlanRelationPO record, Page<DmPlanRelationPO> resultPage)
			throws BaseAppException {
		resultPage = dmPlanRelationService.selectByArgAndPage(record, resultPage);
		return resultPage;
	}

	@RequestMapping("add")
	@ResponseBody
	public DmPlanRelationPO add(DmPlanRelationPO record) throws BaseAppException {
		logger.debug("add record begin...record=[{0}]", record);
		dmPlanRelationService.add(record);
		return record;
	}

	@RequestMapping("addForDraft")
	@ResponseBody
	public DmPlanRelationPO addForDraft(DmPlanRelationPO record) throws BaseAppException {
		logger.debug("add record begin...record=[{0}]", record);
		dmPlanRelationService.addForDraft(record);
		return record;
	}

	@RequestMapping("update")
	@ResponseBody
	public DmPlanRelationPO update(DmPlanRelationPO record) throws BaseAppException {
		logger.debug("modify record begin...record=[{0}]", record);
		dmPlanRelationService.update(record);
		return record;
	}

	@RequestMapping("delete")
	@ResponseBody
	public int delete(DmPlanRelationPO record) throws BaseAppException {
		logger.debug("delete record begin...record=[{0}]", record);
		return dmPlanRelationService.delete(record);
	}

	@RequestMapping("qryRecordInfo")
	@ResponseBody
	public DmPlanRelationPO qryRecordInfo(@RequestParam(value = "dmPlanId", required = true) Integer dmPlanId)
			throws BaseAppException {
		DmPlanRelationPO dprPO = new DmPlanRelationPO();
		dprPO.setDmPlanId(dmPlanId);
		DmPlanRelationPO record = dmPlanRelationService.selectByPrimaryKey(dprPO);
		return record;
	}

}
